package View;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import Controller.Inloggen;
import Controller.Registreren;

@SuppressWarnings("serial")
public class PanelLogin extends JPanel{
	
	private static PanelLogin single;
	private JLabel title = new JLabel("Budget Beheer");
	private JLabel email = new JLabel("E-mail");
	private JLabel password = new JLabel("Wachtwoord");
	
	private JTextField emailField = new JTextField();
	private JPasswordField passwordField = new JPasswordField();
	
	private JButton registerButton = new JButton("Registreren");
	private JButton loginButon = new JButton("Inloggen");
	private JButton JBafsluiten = new JButton("Afsluiten");
	
	private Color backcolor = new Color(239, 238, 237);
	private Color titleColor = new Color(85, 85, 85);
	
	private PanelLogin(){
		
		setLayout(null);

		title.setBounds(350,90,400,70);
		title.setFont(new Font("Serif", Font.BOLD, 50));
		title.setForeground(titleColor);
		title.setBackground(backcolor);
		
		loginButon.setBounds(437,365,125,25);
		registerButton.addActionListener(new Registreren());
		
		registerButton.setBounds(437,400,125,25);
		loginButon.addActionListener(new Inloggen(this));
		

		JBafsluiten.setBounds(437, 550, 125, 25);
		JBafsluiten.addActionListener(new ActionListener() {
			
		
			public void actionPerformed(ActionEvent arg0) {
				MainFrame mf =  MainFrame.getInstance();
						mf.dispose();
			}
		});
		
		email.setBounds(370,275,100,25);
		password.setBounds(370,315,100,25);
		emailField.setBounds(505,275,200, 25);
		passwordField.setBounds(505,315,200, 25);

		add(title);
		add(registerButton);
		add(loginButon);
		add(JBafsluiten);
		add(email);
		add(password);
		add(emailField);
		add(passwordField);

		registerButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				
			}
		});


		
	}
	public static PanelLogin getInstance() {
		if(single == null){
			single = new PanelLogin();
		}
		return single;
	}
	
	public static void selfDestroy(){
		single = null;
	}
	public JLabel getEmail() {
		return email;
	}
	public void setEmail(JLabel email) {
		this.email = email;
	}
	public JLabel getPassword() {
		return password;
	}
	public void setPassword(JLabel password) {
		this.password = password;
	}
	public JTextField getEmailField() {
		return emailField;
	}
	public void setEmailField(JTextField emailField) {
		this.emailField = emailField;
	}
	public JPasswordField getPasswordField() {
		return passwordField;
	}
	public void setPasswordField(JPasswordField passwordField) {
		this.passwordField = passwordField;
	}
	
}
